package com.aizhixin.quick.controller;


import com.aizhixin.quick.mapper.OrganizationMapper;
import com.aizhixin.quick.service.OrganizationService;
import com.aizhixin.quick.utils.Result;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author ${author}
 * @since 2021-08-09
 */
@RestController
@Api(tags = "机构的基础操作")
@RequestMapping("/organization")
public class OrganizationController {

    @Autowired
    OrganizationService organizationService;
    @Autowired
    OrganizationMapper organizationMapper;

/*
查询
 */
@PostMapping("/getAllOrgan")
    public Result getAllOrganization(){
    organizationService.list();
    return Result.ok();
}

/*
新增一级机构
 */
@PostMapping("/addOrgan")
    public Result addOrganization(){
    organizationMapper.insert();
    return Result.ok();
}

/*
修改机构信息
 */
@PostMapping("/updateOrgan")
    public Result updateOrganization(){
     organizationService.saveOrUpdate();
     return Result.ok();
}

/*
根据id删除 机构信息
 */
    @DeleteMapping("/deleteOrgan")
    public Result deleteOrganization(){
        organizationMapper.deleteById();
        return Result.ok();
    }
}

